﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Tag.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the  type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Client.Model
{
    using System.ComponentModel;

    /// <summary>
    /// Defines the <seealso cref="Tag"/> type.
    /// </summary>
    public class Tag : ModelBase, IDataErrorInfo
    {
        #region Data Members

        /// <summary>
        /// Member variable _tagId
        /// </summary>
        private int _tagId;

        /// <summary>
        /// Member variable _name
        /// </summary>
        private string _name;

        /// <summary>
        /// Member variable _userId
        /// </summary>
        private int _userId;

        /// <summary>
        /// Member variable _error
        /// </summary>
        private string _error;

        #endregion Data Members

        /// <summary>
        /// Gets or sets the tag id.
        /// </summary>
        /// <value>
        /// The tag id.
        /// </value>
        public int TagId
        {
            get
            {
                return _tagId;
            }

            set
            {
                _tagId = value;
                RaisePropertyChangedEvent("TagId");
            }
        }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>
        /// The name of tag
        /// </value>
        public string Name
        {
            get
            {
                return _name;
            }

            set
            {
                _name = value;
                RaisePropertyChangedEvent("Name");
            }
        }

        /// <summary>
        /// Gets or sets the user id.
        /// </summary>
        /// <value>
        /// The user id.
        /// </value>
        public int UserId
        {
            get
            {
                return _userId;
            }

            set
            {
                _userId = value;
                RaisePropertyChangedEvent("UserId");
            }
        }

        #region Implementation of IDataErrorInfo

        /// <summary>
        /// Gets an error message indicating what is wrong with this object.
        /// </summary>
        /// <returns>
        /// An error message indicating what is wrong with this object. The default is an empty string ("").
        /// </returns>
        public string Error
        {
            get
            {
                return this._error;
            }
        }

        /// <summary>
        /// Gets the error message for the property with the given name.
        /// </summary>
        /// <returns>
        /// The error message for the property. The default is an empty string ("").
        /// </returns>
        /// <param name="columnName">The name of the property whose error message to get. </param>
        public string this[string columnName]
        {
            get
            {
                string result = null;

                if (columnName == "Name")
                {
                    if (string.IsNullOrWhiteSpace(Name))
                    {
                        result = "Name is required";
                    }
                }

                _error = result;
                return result;
            }
        }

        #endregion Implementation of IDataErrorInfo
    }
}